package util.tools.gas;

import util.exceptions.InvalidDataException;

public class GasData {
    private double[] values;
    /*The argument names should not be taken seriously all the time, esp. for Boyle's Law, Charles', and Gay-Lussac's*/
    public GasData(double pressure, double volume, double temperature, double moles) throws InvalidDataException {
        values = new double[4];
        values[0] = pressure;
        values[1] = volume;
        values[2] = temperature;
        values[3] = moles;
        if (!check())
            throw new InvalidDataException("Too many or too few unknowns");
    }

    public int getMissing() {
        for (int i = 0; i < values.length; i++)
            if (values[i] < 0)
                return i;
        return -1;
    }

    public boolean check() {
        int count = 0;
        for (double v : values)
            if (v < 0)
                count++;
        return count <= 1;
    }


    public double[] getValues() {
        return values;
    }
}
